%function plot_net(connectfile, synfile,neuron_num);
function plot_net(connectfile, synfile,neuron_num);

%connectfile='connect.dat';
[a b c d]=textread(connectfile,'%f%f%f%f%*[^\n]','delimiter','\t');
connect=[a b d]; % x y coord of area & d is cell type index.

X=load(synfile);


%neuron_num=43511+16
neuron_num

for kk=1:length(neuron_num)
    figure(kk)
    ind=find(X(:,1)==neuron_num(kk));
    length(ind)
    hold off
    for ii=1:length(ind)
        % xyz=[connect(X7_19350(ind(ii),2)+1,[1,2,8]);connect(X7_19350(ind(ii),1)+1,[1,2,8])];
        xyz0=connect(X(ind(ii),2)+1,:);
        plot3(xyz0(:,1),xyz0(:,2),xyz0(:,3)+1,'.');

        hold on
    end;
    xyz1=connect(X(ind(1),1)+1,:);
    plot3(xyz1(:,1),xyz1(:,2),xyz1(:,3)+1,'r*');
    
    title(['Neurons connected to cell #: * ', num2str(neuron_num(kk))]);
    pause;
    clear ind
end;





  